#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

vector<string> split(string str, string pattern)
{
	string::size_type pos;
	vector<string> result;
	str += pattern;
	int size = str.size();
	for (int i = 0; i < size; i++)

	{
		pos = str.find(pattern, i);
		if (pos < size)
		{
			string s = str.substr(i, pos - i);
			result.push_back(s);
			i = pos + pattern.size() - 1;
		}
	}
	return result;
}

void checkInvalid(string &str) {
	for (auto it = str.begin(); it != str.end(); ++it) {
		if (!isalpha(*it))
			*it = ' ';
	}
}

void wordsReverse(string &str) {
	checkInvalid(str);
	vector<string> words = split(str, " ");
	reverse(words.begin(), words.end());
	for (auto it = words.begin(); it != words.end();) {
		if (*it == "")
			it = words.erase(it);
		else ++it;
	}
	for (auto word : words)
		cout << word << " ";
	cout << endl;
}

int main() {
	string str;
	getline(cin, str);
	wordsReverse(str);
}
